/*
	@file: /log/source/formatter/DatetimeFormatter.cpp
	@author: Wolfhead
 */
#include "formatter/DatetimeFormatter.h"
#include <time.h>
#include <sys/time.h>
#include <vector>
#include <boost/date_time/posix_time/posix_time.hpp>


namespace logger
{

DatetimeFormatter::DatetimeFormatter(const std::string format)
	: m_format(format)
{

}

void DatetimeFormatter::do_format(
	LogDataPtr data_ptr,
	std::string & output)
{
	struct tm st_time(boost::posix_time::to_tm(data_ptr->context.time));

	char buffer[128];
	strftime(buffer, sizeof(buffer)-1, m_format.c_str(), 
		&st_time);

	output.append(buffer);
}


}//namespace logger
